home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 05.zip
/
BS1 part 5
/
IM_Install3.adf
/
piarc.LZH
/
graphr.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-02-29
|
6KB
|
224 lines
/*
* GRAPHr.rexx draw a GRAPH in the Image in IM
*
* Written by: Barry Chalmers & Ben Williams
* Last Update: January 17th, 1992
* For: Black Belt Systems image processing series IM, IM F/c, and IP.
* ---------------------------------------------------------------------------
* Revision: 1.01 - see ReadMe file for details on changes to this level
*/
/*
* open rexxsupport.library -- needed for some functions
*/
if ~show('L',"rexxsupport.library") then do
if addlib('rexxsupport.library',0,-30,0) then do
/* everything's ok */
end;
else do
say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
say 'Cannot operate JPEG.rexx without this library - sorry!';
exit 10;
end;
end;
/*
* This will automatically direct the script to the proper
* software, if it is running. No matter where the script is
* launched from.
*/
prtnme = 'IP_Port'; /* assume Image Professional */
if show('P','IP_Port') = 0 then do
if show('P','IM_Port') = 0 then do
say "Can't find image processor's ARexx port!!!"; /* not running? */
say "This script requires IP, IM or IM F/c to run!";
exit(20);
end;
else do
prtnme = 'IM_Port'; /* That's the thing about assumptions... */
end; /* We make em, user's break em. */
end;
/*
* This code attempts to read a file called "picmdpath" from REXX:
* If it can't find it, the script will assume that the commands
* associated with this PI Module are in "c:". If the file exists,
* the script will look in the path that is specified in the file.
* If you create this file, you MUST put a complete, correct path
* in it; if the commands are in a sub-directory, you have to put
* the trailing slash on the path (like, device:dir/).
*
*/
cmdpath = 'c:';
if open(fhandle,'rexx:picmdpath','read') then /* open the file */
do
cmdpath = readln(fhandle);
call close(fhandle); /* close the file */
end
/*
* Get the file name parts
*/
prevpath = 'ram:';
if show('C',graphpath) = 1 then do
prevpath = getclip(graphpath);
end;
prevname = 'image';
if show('C',graphname) = 1 then do
prevname = getclip(graphname);
end;
prevext = '.table';
if show('C',graphext) = 1 then do
prevext = getclip(graphext);
end;
width = 320;
if show('C',graphwidth) = 1 then do
width = getclip(graphwidth);
end;
height = 200;
if show('C',graphheight) = 1 then do
height = getclip(graphheight);
end;
address(prtnme);
options results;
'filerequest "'||prevpath||'" "'||prevname||'" "'||prevext||'" '||'"Get Table"';
graphfile = result;
options;
call checkfile(graphfile);
options results;
'asknumber "Width (X)","'||width;
width = result;
options;
call setclip(graphwidth,width);
options results;
'asknumber "Height (Y)","'||height;
height = result;
options;
call setclip(graphheight,height);
'autoredraw 0';
'newasprimary '||width||' '||height;
options results;
'jackin';
stuff = result;
'current';
bufdata = result;
options;
parse var bufdata bname ',' bnum ',' brest
'lockimage '||bnum;
address command cmdpath||'graph '||stuff||' '||graphfile;
'unlockimage '||bnum;
address(prtnme);
'tofront';
'redraw';
address;
exit 0;
checkfile:
arg thefile;
if thefile = 'FR_CANCELLED' then do
'tofront';
exit 0;
end;
prevpath = gimmepath(thefile);
call setclip(graphpath,prevpath);
prevname = gimmename(thefile);
call setclip(graphname,prevname);
prevext = gimmeext(thefile);
call setclip(graphext,prevext);
return;
end
/*
* gimmepath
*
* This takes the provided argument and sucks the path out of it, then
* returns that path to the caller, sans file name.
*/
gimmepath:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
gxpath = left(fullnamegx,seploc);
return(gxpath);
end
gimmename:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
extpos = lastpos(".",fullnamegx) - 2;
if extpos > seploc then do
gxname = substr(fullnamegx,seploc+1,extpos-seploc+1);
end;
else do
gxname = substr(fullnamegx,seploc+1);
end;
return(gxname);
end
gimmeext:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
extpos = lastpos(fullnamegx,'.');
if extpos > seploc then do
gxext = substr(fullnamegx,extpos+1);
end
else do
gxext = '';
end
return(gxext);
end